﻿﻿@model WebApp.Models.ORDER
<!-- 弹出窗体form表单 -->
 <div id="detailswindow" hidden="hidden" class="easyui-window" 
      title="明细数据" 
      data-options="modal:true,
                    closed:true,
                    maximized:false,
                    iconCls:'icon-more',
                    footer:'#windowfooter',
                    closeDuration:200,
                    closeAnimation:'slide',
                    openDuration:300,
                    openAnimation:'slide',
                    onBeforeClose:function(){
                      var that = $(this);
                      if(hasmodified()){
                        $.messager.confirm('确认','你确定要放弃保存修改的记录?',function(r){
                        if (r){
                          var opts = that.panel('options');
                          var onBeforeClose = opts.onBeforeClose;
                          opts.onBeforeClose = function(){};
                          that.panel('close');
                          opts.onBeforeClose = onBeforeClose;
                        }
                        });
                        return false;
                      }
                    },
                    onOpen:function(){
                       $(this).window('vcenter');
                       $(this).window('hcenter');
                    },
                    onRestore:function(){
                      $orderdetailsdg.datagrid('resize');
                      $pickdetailsdg.datagrid('resize');
                    },
                    onMaximize:function(){
                      $orderdetailsdg.datagrid('resize');
                      $pickdetailsdg.datagrid('resize');
                    }
                    " style="width:1350px;height:520px">
    <!-- begin toolbar -->
    <div class="window-body-toolbar">
        <div class="row">
            <div class="col-sm-8">
                <div class="btn-group btn-group-sm">
                       <button onclick="saveitem()" class="btn btn-default"> 
                          <i class="fa fa-floppy-o"></i> 保存 
                       </button>
                </div>
                <div class="btn-group btn-group-sm" style="display:none">
                    <button onclick="todo()" class="btn btn-default">
                        <i class="fa fa-print"></i> ToDo
                    </button>
                </div>
            </div>
            <div class="col-sm-4 text-align-right">
              <div class="btn-group btn-group-sm">
                <button type="button" class="btn   btn-success" onclick="closedetailwindow()">
                    <i class="fa fa-chevron-left"></i>
                    关闭
                </button>
              </div>
            </div>
        </div>
    </div>
    <!-- end toolbar -->
    <!-- begin window body -->
    <div class="padding-10">
    <!-- begin form表单界面-->
        <div class="row">
            <div class="col-md-12">
          <form id="order_form" 
              class="easyui-form form-horizontal padding-10" 
              method="post" 
              data-options="novalidate:true,
                            onChange: function(target){
                              hasChanged = true;
                             },
                             onLoadSuccess:function(data){
                               hasChanged = false;
                             }">
  @Html.AntiForgeryToken()
   <!--Primary Key-->
  <input type="hidden" id="@Html.IdFor(model => model.ID)" 
                       name="@Html.NameFor(model => model.ID)" 
                       value="@Html.ValueFor(model => model.ID)" />
    <!--SUSR3-->
  <input type="hidden" id="@Html.IdFor(model => model.SUSR3)" 
                       name="@Html.NameFor(model => model.SUSR3)" 
                       value="@Html.ValueFor(model => model.SUSR3)" />
   <!--SUSR4-->
  <input type="hidden" id="@Html.IdFor(model => model.SUSR4)" 
                       name="@Html.NameFor(model => model.SUSR4)" 
                       value="@Html.ValueFor(model => model.SUSR4)" />
   <!--SUSR5-->
  <input type="hidden" id="@Html.IdFor(model => model.SUSR5)" 
                       name="@Html.NameFor(model => model.SUSR5)" 
                       value="@Html.ValueFor(model => model.SUSR5)" />
   <!--SUSR6-->
  <input type="hidden" id="@Html.IdFor(model => model.SUSR6)" 
                       name="@Html.NameFor(model => model.SUSR6)" 
                       value="@Html.ValueFor(model => model.SUSR6)" />
   <!--SUSR7-->
  <input type="hidden" id="@Html.IdFor(model => model.SUSR7)" 
                       name="@Html.NameFor(model => model.SUSR7)" 
                       value="@Html.ValueFor(model => model.SUSR7)" />
   <!--SUSR8-->
  <input type="hidden" id="@Html.IdFor(model => model.SUSR8)" 
                       name="@Html.NameFor(model => model.SUSR8)" 
                       value="@Html.ValueFor(model => model.SUSR8)" />
 
 <table class="table table-bordered"> 
	    <tr>
	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.ORDERKEY)</span></td>
	   <td> 
            <!--出货单号-->
			<input id="@Html.IdFor(model => model.ORDERKEY)" 
				   name="@Html.NameFor(model => model.ORDERKEY)" 
				   value="@Html.ValueFor(model => model.ORDERKEY)"
				   tabindex="0" required
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.ORDERKEY)',
								 label:'',
                                 width:200,
								 required:true,
                                 validType: 'length[0,20]'
                                 " />
				   </td>
	   	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.WHSEID)</span></td>
	   <td> 
            <!--仓库号-->
			<input id="@Html.IdFor(model => model.WHSEID)" 
				   name="@Html.NameFor(model => model.WHSEID)" 
				   value="@Html.ValueFor(model => model.WHSEID)"
				   tabindex="1" required
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.WHSEID)',
								 label:'',
                                 width:200,
								 required:true,
                                 validType: 'length[0,20]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.EXTERNORDERKEY)</td>
	   <td> 
            <!--批次号-->
			<input id="@Html.IdFor(model => model.EXTERNORDERKEY)" 
				   name="@Html.NameFor(model => model.EXTERNORDERKEY)" 
				   value="@Html.ValueFor(model => model.EXTERNORDERKEY)"
				   tabindex="2" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.EXTERNORDERKEY)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,50]'
                                 " />
				   </td>
	   	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.STATUS)</span></td>
	   <td> 
            <!--状态-->
			<input id="@Html.IdFor(model => model.STATUS)" 
				   name="@Html.NameFor(model => model.STATUS)" 
				   value="@Html.ValueFor(model => model.STATUS)"
				   tabindex="3" required
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.STATUS)',
								 label:'',
                                 width:200,
								 required:true,
                                 validType: 'length[0,3]'
                                 " />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.ORDERDATE)</span></td>
	   <td> 
               <!--订单日期-->
                <input id="@Html.IdFor(model => model.ORDERDATE)" 
			       name="@Html.NameFor(model => model.ORDERDATE)"
                   value="@Html.ValueFor(model => model.ORDERDATE)"
           		   tabindex="4"  required
				   class="easyui-datebox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.ORDERDATE)',
								 label:'',
                                 width:200,
								 required:true,
								 formatter:dateformatter" />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.REQUESTEDSHIPDATE)</td>
	   <td> 
               <!--配送日期-->
                <input id="@Html.IdFor(model => model.REQUESTEDSHIPDATE)" 
			       name="@Html.NameFor(model => model.REQUESTEDSHIPDATE)"
                   value="@Html.ValueFor(model => model.REQUESTEDSHIPDATE)"
           		   tabindex="5"  
				   class="easyui-datebox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.REQUESTEDSHIPDATE)',
								 label:'',
                                 width:200,
								 required:false,
								 formatter:dateformatter" />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.DELIVERYDATE)</td>
	   <td> 
               <!--要求到货时间-->
                <input id="@Html.IdFor(model => model.DELIVERYDATE)" 
			       name="@Html.NameFor(model => model.DELIVERYDATE)"
                   value="@Html.ValueFor(model => model.DELIVERYDATE)"
           		   tabindex="6"  
				   class="easyui-datebox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.DELIVERYDATE)',
								 label:'',
                                 width:200,
								 required:false,
								 formatter:dateformatter" />
				   </td>
	   	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.STORERKEY)</span></td>
	   <td> 
            <!--货主-->
			<input id="@Html.IdFor(model => model.STORERKEY)" 
				   name="@Html.NameFor(model => model.STORERKEY)" 
				   value="@Html.ValueFor(model => model.STORERKEY)"
				   tabindex="7" required
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.STORERKEY)',
								 label:'',
                                 width:200,
								 required:true,
                                 validType: 'length[0,50]'
                                 " />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label">@Html.DisplayNameFor(model => model.TYPE)</td>
	   <td> 
            <!--出货方式-->
			<input id="@Html.IdFor(model => model.TYPE)" 
				   name="@Html.NameFor(model => model.TYPE)" 
				   value="@Html.ValueFor(model => model.TYPE)"
				   tabindex="8" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.TYPE)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,10]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.SUPPLIERCODE)</td>
	   <td> 
            <!--供应商代码-->
			<input id="@Html.IdFor(model => model.SUPPLIERCODE)" 
				   name="@Html.NameFor(model => model.SUPPLIERCODE)" 
				   value="@Html.ValueFor(model => model.SUPPLIERCODE)"
				   tabindex="9" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.SUPPLIERCODE)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,20]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.SUPPLIERNAME)</td>
	   <td> 
            <!--供应商名称-->
			<input id="@Html.IdFor(model => model.SUPPLIERNAME)" 
				   name="@Html.NameFor(model => model.SUPPLIERNAME)" 
				   value="@Html.ValueFor(model => model.SUPPLIERNAME)"
				   tabindex="10" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.SUPPLIERNAME)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,80]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.SUSR2)</td>
	   <td> 
            <!--配送厂区-->
			<input id="@Html.IdFor(model => model.SUSR2)" 
				   name="@Html.NameFor(model => model.SUSR2)" 
				   value="@Html.ValueFor(model => model.SUSR2)"
				   tabindex="11" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.SUSR2)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,80]'
                                 " />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label">@Html.DisplayNameFor(model => model.CONSIGNEEKEY)</td>
	   <td> 
            <!--收货单位-->
			<input id="@Html.IdFor(model => model.CONSIGNEEKEY)" 
				   name="@Html.NameFor(model => model.CONSIGNEEKEY)" 
				   value="@Html.ValueFor(model => model.CONSIGNEEKEY)"
				   tabindex="12" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.CONSIGNEEKEY)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,30]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.CONSIGNEENAME)</td>
	   <td> 
            <!--收货单位名称-->
			<input id="@Html.IdFor(model => model.CONSIGNEENAME)" 
				   name="@Html.NameFor(model => model.CONSIGNEENAME)" 
				   value="@Html.ValueFor(model => model.CONSIGNEENAME)"
				   tabindex="13" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.CONSIGNEENAME)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,80]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.CONSIGNEEADDRESS)</td>
	   <td> 
            <!--收货地址-->
			<input id="@Html.IdFor(model => model.CONSIGNEEADDRESS)" 
				   name="@Html.NameFor(model => model.CONSIGNEEADDRESS)" 
				   value="@Html.ValueFor(model => model.CONSIGNEEADDRESS)"
				   tabindex="14" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.CONSIGNEEADDRESS)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,80]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.CARRIERNAME)</td>
	   <td> 
            <!--承运人-->
			<input id="@Html.IdFor(model => model.CARRIERNAME)" 
				   name="@Html.NameFor(model => model.CARRIERNAME)" 
				   value="@Html.ValueFor(model => model.CARRIERNAME)"
				   tabindex="15" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.CARRIERNAME)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,80]'
                                 " />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label">@Html.DisplayNameFor(model => model.DRIVERNAME)</td>
	   <td> 
            <!--司机-->
			<input id="@Html.IdFor(model => model.DRIVERNAME)" 
				   name="@Html.NameFor(model => model.DRIVERNAME)" 
				   value="@Html.ValueFor(model => model.DRIVERNAME)"
				   tabindex="16" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.DRIVERNAME)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,20]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.CARRIERPHONE)</td>
	   <td> 
            <!--司机电话-->
			<input id="@Html.IdFor(model => model.CARRIERPHONE)" 
				   name="@Html.NameFor(model => model.CARRIERPHONE)" 
				   value="@Html.ValueFor(model => model.CARRIERPHONE)"
				   tabindex="17" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.CARRIERPHONE)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,20]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.TRAILERNUMBER)</td>
	   <td> 
            <!--运输车辆-->
			<input id="@Html.IdFor(model => model.TRAILERNUMBER)" 
				   name="@Html.NameFor(model => model.TRAILERNUMBER)" 
				   value="@Html.ValueFor(model => model.TRAILERNUMBER)"
				   tabindex="18" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.TRAILERNUMBER)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,80]'
                                 " />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.ACTUALSHIPDATE)</td>
	   <td> 
               <!--实际配送日期-->
                <input id="@Html.IdFor(model => model.ACTUALSHIPDATE)" 
			       name="@Html.NameFor(model => model.ACTUALSHIPDATE)"
                   value="@Html.ValueFor(model => model.ACTUALSHIPDATE)"
           		   tabindex="19"  
				   class="easyui-datebox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.ACTUALSHIPDATE)',
								 label:'',
                                 width:200,
								 required:false,
								 formatter:dateformatter" />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label">@Html.DisplayNameFor(model => model.ACTUALDELIVERYDATE)</td>
	   <td> 
               <!--实际到货时间-->
                <input id="@Html.IdFor(model => model.ACTUALDELIVERYDATE)" 
			       name="@Html.NameFor(model => model.ACTUALDELIVERYDATE)"
                   value="@Html.ValueFor(model => model.ACTUALDELIVERYDATE)"
           		   tabindex="20"  
				   class="easyui-datebox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.ACTUALDELIVERYDATE)',
								 label:'',
                                 width:200,
								 required:false,
								 formatter:dateformatter" />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.CLOSEDDATE)</td>
	   <td> 
               <!--结案日期-->
                <input id="@Html.IdFor(model => model.CLOSEDDATE)" 
			       name="@Html.NameFor(model => model.CLOSEDDATE)"
                   value="@Html.ValueFor(model => model.CLOSEDDATE)"
           		   tabindex="21"  
				   class="easyui-datebox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.CLOSEDDATE)',
								 label:'',
                                 width:200,
								 required:false,
								 formatter:dateformatter" />
				   </td>
	   	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.TOTALQTY)</span></td>
	   <td> 
             <!--合计出货数量-->
             <input id="@Html.IdFor(model => model.TOTALQTY)"
				   name="@Html.NameFor(model => model.TOTALQTY)" 
				   value="@Html.ValueFor(model => model.TOTALQTY)"
				   tabindex="22" 
				   class="easyui-numberbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.TOTALQTY)',
								 label:'',
                                 width:200,
								 required:true,
                                 precision:2,
                                 validType:'decimal',
                                 
                                 "  />
				   </td>
	   	   <td class="control-label"><span class="required">@Html.DisplayNameFor(model => model.OPENQTY)</span></td>
	   <td> 
             <!--合计未出数量-->
             <input id="@Html.IdFor(model => model.OPENQTY)"
				   name="@Html.NameFor(model => model.OPENQTY)" 
				   value="@Html.ValueFor(model => model.OPENQTY)"
				   tabindex="23" 
				   class="easyui-numberbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.OPENQTY)',
								 label:'',
                                 width:200,
								 required:true,
                                 precision:2,
                                 validType:'decimal',
                                 
                                 "  />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label">@Html.DisplayNameFor(model => model.TOTALPACKAGE)</td>
	   <td> 
             <!--合计件数-->
             <input id="@Html.IdFor(model => model.TOTALPACKAGE)"
				   name="@Html.NameFor(model => model.TOTALPACKAGE)" 
				   value="@Html.ValueFor(model => model.TOTALPACKAGE)"
				   tabindex="24" 
				   class="easyui-numberbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.TOTALPACKAGE)',
								 label:'',
                                 width:200,
								 required:false,
                                 precision:2,
                                 validType:'decimal',
                                 
                                 "  />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.TOTALGROSSWEIGHT)</td>
	   <td> 
             <!--合计毛重(KG)-->
             <input id="@Html.IdFor(model => model.TOTALGROSSWEIGHT)"
				   name="@Html.NameFor(model => model.TOTALGROSSWEIGHT)" 
				   value="@Html.ValueFor(model => model.TOTALGROSSWEIGHT)"
				   tabindex="25" 
				   class="easyui-numberbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.TOTALGROSSWEIGHT)',
								 label:'',
                                 width:200,
								 required:false,
                                 precision:2,
                                 validType:'decimal',
                                 
                                 "  />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.TOTALVOLUME)</td>
	   <td> 
             <!--合计体积(M)-->
             <input id="@Html.IdFor(model => model.TOTALVOLUME)"
				   name="@Html.NameFor(model => model.TOTALVOLUME)" 
				   value="@Html.ValueFor(model => model.TOTALVOLUME)"
				   tabindex="26" 
				   class="easyui-numberbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.TOTALVOLUME)',
								 label:'',
                                 width:200,
								 required:false,
                                 precision:2,
                                 validType:'decimal',
                                 
                                 "  />
				   </td>
	   	   <td class="control-label">@Html.DisplayNameFor(model => model.NOTES)</td>
	   <td> 
            <!--备注-->
			<input id="@Html.IdFor(model => model.NOTES)" 
				   name="@Html.NameFor(model => model.NOTES)" 
				   value="@Html.ValueFor(model => model.NOTES)"
				   tabindex="27" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.NOTES)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,100]'
                                 " />
				   </td>
	   	   </tr>
	   	    <tr>
	   <td class="control-label">@Html.DisplayNameFor(model => model.SUSR1)</td>
	   <td> 
            <!--上传用户-->
			<input id="@Html.IdFor(model => model.SUSR1)" 
				   name="@Html.NameFor(model => model.SUSR1)" 
				   value="@Html.ValueFor(model => model.SUSR1)"
				   tabindex="28" 
				   class="easyui-textbox" 
				   type="text" 
				   data-options="prompt:'@Html.DisplayNameFor(model => model.SUSR1)',
								 label:'',
                                 width:200,
								 required:false,
                                 validType: 'length[0,50]'
                                 " />
				   </td>
	   	    		<td></td> <td></td>
			<td></td> <td></td>
			<td></td> <td></td>
		     </tr>
	       </table>
     </form>
     </div>
    </div>
<!--end form表单界面-->
<!--========================================================================================-->
     <!-- begin details row -->
    <div class="row">
        <div class="col-md-12">
    <!-- details tabs -->
    <div class="tabs-container">
        <!-- Nav tabs -->
        <ul class="nav nav-tabs bordered">
								<li class="active"><a data-toggle="tab" href="#tab-orderdetails"> ORDERDETAILS</a></li>
												<li class=""><a data-toggle="tab" href="#tab-pickdetails"> PICKDETAILS</a></li>	 		 
				   
		 </ul>
		 <!-- Tab panes -->
         <div class="tab-content">
		  		  <div id="tab-orderdetails" class="tab-pane active">
                  <div class="panel-body-toolbar">
                                    <div class="row">
                                        <div class="col-sm-8  ">
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="orderdetails_append()" class="btn btn-default"> <i class="fa fa-plus"></i> 新增 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="orderdetails_removeit()" class="btn  btn-default"> <i class="fa fa-trash-o"></i> 删除 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="orderdetails_accept()" class="btn  btn-default"> <i class="fa fa-floppy-o"></i> 保存 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="orderdetails_reload()" class="btn btn-default"> <i class="fa fa-refresh"></i> 刷新 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="orderdetails_reject()" class="btn  btn-default"> <i class="fa fa-window-close-o"></i> 取消 </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                <div class="table-responsive">
				<table id="orderdetails_datagrid" >
                </table>
			
            </div>
            </div>
		  		  <div id="tab-pickdetails" class="tab-pane ">
                  <div class="panel-body-toolbar">
                                    <div class="row">
                                        <div class="col-sm-8  ">
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="pickdetails_append()" class="btn btn-default"> <i class="fa fa-plus"></i> 新增 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="pickdetails_removeit()" class="btn  btn-default"> <i class="fa fa-trash-o"></i> 删除 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="pickdetails_accept()" class="btn  btn-default"> <i class="fa fa-floppy-o"></i> 保存 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="pickdetails_reload()" class="btn btn-default"> <i class="fa fa-refresh"></i> 刷新 </button>
                                            </div>
                                            <div class="btn-group btn-group-sm">
                                                <button onclick="pickdetails_reject()" class="btn  btn-default"> <i class="fa fa-window-close-o"></i> 取消 </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                <div class="table-responsive">
				<table id="pickdetails_datagrid" >
                </table>
			
            </div>
            </div>
		  	</div>
	</div>
	</div>
	</div> 
<!--end details tabs -->
    </div>
    <!--end window body -->
</div>
<div id="windowfooter" style="padding:5px;">&nbsp;</div>
<!-- 弹出窗体form表单 -->
<!-- 弹出编辑对话框 -->
<!-- orderdetail datagrid  javascript block -->
@Html.Partial("_ORDERDETAILEditForm", new WebApp.Models.ORDERDETAIL())
<!-- pickdetail datagrid  javascript block -->
@Html.Partial("_PICKDETAILEditForm", new WebApp.Models.PICKDETAIL())
<!--begin popup detailview javascript block -->
<script type="text/javascript">
    //判断新增编辑状态
    var MODELSTATE = 'Added';
    var orderid = null;
    var hasChanged = false;
    function opendetailwindow(data,state) {
         initdetailview();
         MODELSTATE = state;
         orderid = (data.ID || 0);
         $("#detailswindow").window("open");
         $('#order_form').form('reset');
         $('#order_form').form('load', data);
                   var url='/ORDERDETAILS/GetDataByORDERIDAsync?orderid=' +  orderid;
          $orderdetailsdg.datagrid('load',url);
          $orderdetailsdg.datagrid('resize');
                   var url='/PICKDETAILs/GetDataByORDERIDAsync?orderid=' +  orderid;
          $pickdetailsdg.datagrid('load',url);
          $pickdetailsdg.datagrid('resize');
             }
    
    //async 保存数据
    async function saveitem() { 
      var $editform = $('#order_form');
      if ($editform.form('enableValidation').form('validate')) {
            let order = $editform.serializeJSON();
            				  //获取明细表数据
		    
                      const orderdetails_res = await orderdetails_accept();
                      if (!orderdetails_res.success) {
                              return false;
                      } else {
                        if (orderdetails_res.changed) {
                           order.ORDERDETAILS = orderdetails_res.changed;
                        }
                      }
                      
            
                      const pickdetails_res = await pickdetails_accept();
                      if (!pickdetails_res.success) {
                              return false;
                      } else {
                        if (pickdetails_res.changed) {
                           order.PICKDETAILS = pickdetails_res.changed;
                        }
                      }
                      
           		               let url = '/ORDERs/EditAsync';
            //判断是新增或是修改方法
            if (MODELSTATE === 'Added') {
                url = '/ORDERs/CreateAsync';
            }
            var token = $('input[name="__RequestVerificationToken"]', $editform).val();
            $.ajax({
                    type: "POST",
                    url: url,
                    data: {
                        __RequestVerificationToken: token,
                        order:order
                    },
                    dataType: 'json',
                    contentType: 'application/x-www-form-urlencoded; charset=utf-8'
                })
                .done(response => {
                    if (response.success) {
                        hasChanged = false;
                        $editform.form('disableValidation');
                        $dg.datagrid('reload');
                        $('#detailswindow').window("close");
                        toastr.success("保存成功");  
                    } else {
                        $.messager.alert("错误",   response.err, "error");
                    }
                    })
                .fail((jqXHR, textStatus, errorThrown) => {
                       $.messager.alert('异常', `${jqXHR.status}: ${jqXHR.statusText} `, 'error');
                    });
        }
    }
    //关闭窗口
    function closedetailwindow() {
        $('#detailswindow').window('close');
    }
    //todo
    function todo() {
         console.log('todo.....');
    }
     //判断是否有没有保存的记录
     function hasmodified() {
      if(hasChanged) return hasChanged;
            if (!orderdetails_endEditing()) {
                 return true;
             }
            const orderdetails = $orderdetailsdg.datagrid("getChanges");
            if (MODELSTATE == 'Modified' && orderdetails.length > 0) {
                return true;
            }
            if (!pickdetails_endEditing()) {
                 return true;
             }
            const pickdetails = $pickdetailsdg.datagrid("getChanges");
            if (MODELSTATE == 'Modified' && pickdetails.length > 0) {
                return true;
            }
            return false;

     }


function initdetailview() {

    $('a[data-toggle="tab"]').on('shown.bs.tab', e => {
        const target = $(e.target).attr("href");
                if(target === "#tab-orderdetails")
             $orderdetailsdg.datagrid("resize");
              if(target === "#tab-pickdetails")
             $pickdetailsdg.datagrid("resize");
            });
 
//回车光标移动到下个输入控件
    //如果是枚举类型需要把numberbox改成combobox
    //合计出货数量
	$('#TOTALQTY').numberbox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //如果是枚举类型需要把numberbox改成combobox
    //合计未出数量
	$('#OPENQTY').numberbox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //如果是枚举类型需要把numberbox改成combobox
    //合计件数
	$('#TOTALPACKAGE').numberbox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //如果是枚举类型需要把numberbox改成combobox
    //合计毛重(KG)
	$('#TOTALGROSSWEIGHT').numberbox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //如果是枚举类型需要把numberbox改成combobox
    //合计体积(M)
	$('#TOTALVOLUME').numberbox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //如果是枚举类型需要把numberbox改成combobox
    //SUSR6
	//$('#SUSR6').numberbox('textbox').bind('keydown', function (e) {
    //  if (e.keyCode == 13) {
    //    $(e.target).emulateTab();
    //  }
    //});
    //如果是枚举类型需要把numberbox改成combobox
    //SUSR7
	//$('#SUSR7').numberbox('textbox').bind('keydown', function (e) {
    //  if (e.keyCode == 13) {
    //    $(e.target).emulateTab();
    //  }
    //});
    //日期类型 订单日期
	$('#ORDERDATE').datebox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //日期类型 配送日期
	$('#REQUESTEDSHIPDATE').datebox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //日期类型 要求到货时间
	$('#DELIVERYDATE').datebox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //日期类型 实际配送日期
	$('#ACTUALSHIPDATE').datebox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //日期类型 实际到货时间
	$('#ACTUALDELIVERYDATE').datebox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //日期类型 结案日期
	$('#CLOSEDDATE').datebox('textbox').bind('keydown', function (e) {
      if (e.keyCode == 13) {
        $(e.target).emulateTab();
      }
    });
    //日期类型 SUSR8
	//$('#SUSR8').datebox('textbox').bind('keydown', function (e) {
    //  if (e.keyCode == 13) {
    //    $(e.target).emulateTab();
    //  }
    //});
}
</script>

